//
//  AddfriedViewController.m
//  LeDiao
//
//  Created by admin on 16/2/29.
//  Copyright © 2016年 xuxuan. All rights reserved.
//
//ViewControllers
#import "MyFriendViewController.h"
#import "LoginController.h"
#import "GroupViewController.h"
#import "FriendViewController.h"
//Views
@interface MyFriendViewController (){
    FriendViewController *myVC1;
    GroupViewController *myVC2;
}

@property (strong, nonatomic) UIViewController *currentVC;

@end

@implementation MyFriendViewController

- (void)viewDidLoad {
    self.view.backgroundColor = [UIColor redColor];
    _contentView.backgroundColor= [UIColor redColor];
    [super viewDidLoad];
    self.title = @"我的钓友/群";
    self.view.backgroundColor =BackGray;
    
    myVC1 = [[FriendViewController alloc]init];
    [self addChildViewController:myVC1];
    
    myVC2 = [[GroupViewController alloc]init];
    myVC2.view.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight - 110);
    [self addChildViewController:myVC2];
    
    [self.contentView addSubview:myVC1.view];
    self.currentVC  = myVC1;
    
}
- (id)init{
    self = [super init];
    if (self) {
        self.hidesBottomBarWhenPushed = YES;
    }
    return self;
}
- (void)viewWillAppear:(BOOL)animated{
    animated = YES;
    self.navigationController.navigationBarHidden=NO;
    self.tabBarController.tabBar.hidden =YES;
}

- (IBAction)segmentAction:(id)sender {

    UIViewController *oldVC = self.currentVC;
    
    switch ([sender selectedSegmentIndex]) {
        case 0:
        {
            [self transitionFromViewController:self.currentVC toViewController:myVC1 duration:0.3 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
                nil;
            } completion:^(BOOL finished) {
                if(finished) {
                    self.currentVC = myVC1;
                }
                else {
                    self.currentVC = oldVC;
                }
               
            }];
        }
            break;
        case 1:{
            
            [self transitionFromViewController:self.currentVC toViewController:myVC2 duration:0.3 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
                nil;
            } completion:^(BOOL finished) {
                if(finished) {
                    self.currentVC = myVC2;
                }
                else {
                    self.currentVC = oldVC;
                }
                
            }];
 
        }
            break;
        default:
            break;
    }
}
- (IBAction)tapbackgroundview:(id)sender {
    if(self.currentVC==myVC1 ) {
//        [CondiVC.searchbar resignFirstResponder];
        return;
    }
    
    if(self.currentVC==myVC2 ) {
        return;
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
@end
